{include file="public_head" /}

<!-- datatables -->
<link href="__STATIC__/js/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- chk_3 -->
<link href="__STATIC__/css/chk_3.css" rel="stylesheet" type="text/css"/>

<body class="nav-md">

<div class="container body">


    <div class="main_container">

        {include file="public_sidebar,public_nav" /}

        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">
                        <h3>
                            订单管理
                        </h3>
                    </div>
                </div>
                <div class="clearfix"></div>

                <div class="row">

                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>{$mate_title}
                                    <!--<small>promotion</small>-->
                                </h2>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <form name="form" id="form" method="get" action="">

                                    <div class="title_left">
                                        <div class="col-md-7 col-sm-3 col-xs-12 form-group pull-left top_search">
                                            <div class="input-group" style="float: left;margin: 0 20px;">

                                                <select name="way" class="select2_single" style="width: 200px;"
                                                        tabindex="-1">
                                                    <option value="0">- 请选择支付状态 -</option>
                                                    <option value="未支付" {eq name=':input("way")' value='未支付' }selected{/eq}>未支付</option>
                                                    <option value="余额支付" {eq name=':input("way")' value='余额支付' }selected{/eq}>余额支付</option>
                                                    <option value="支付宝" {eq name=':input("way")' value='支付宝' }selected{/eq}>支付宝</option>
                                                    <option value="微信" {eq name=':input("way")' value='微信' }selected{/eq}>微信</option>
                                                    <option value="退款" {eq name=':input("way")' value='退款' }selected{/eq}>退款</option>
                                                </select>
                                            </div>
                                            <div class="input-group" style="float: left;margin: 0 20px;">

                                                <select name="status" id="status" class="select2_single" style="width: 200px;"
                                                        tabindex="-1">
                                                    <option value="-1">- 请选择订单状态 -</option>
                                                    <option value="0" {eq name=':input("status")' value='0' }selected{/eq}>未支付</option>
                                                    <option value="1" {eq name=':input("status")' value='1' }selected{/eq}>已支付</option>
                                                    <option value="2" {eq name=':input("status")' value='2' }selected{/eq}>已发货</option>
                                                    <option value="3" {eq name=':input("status")' value='3' }selected{/eq}>已收货</option>
                                                    <option value="4" {eq name=':input("status")' value='4' }selected{/eq}>已完结</option>
                                                    <option value="5" {eq name=':input("status")' value='5' }selected{/eq}>已取消</option>
                                                    <option value="6" {eq name=':input("status")' value='6' }selected{/eq}>申请退款</option>
                                                    <option value="7" {eq name=':input("status")' value='7' }selected{/eq}>退款成功</option>
                                                </select>
                                            </div>
                                            <div class="input-group" style="float: left;margin: 0 20px;">
                                                <input type="text" class="form-control" name="interval_timer"
                                                       id="interval_timer"
                                                       style="width: 200px;"
                                                       placeholder="请选择时间区间..." value="{:input('interval_timer')}">
                                            </div>
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="title"
                                                       placeholder="输入搜索内容..." value="{:input('title')}">
                                            </div>
                                        </div>
                                        <button type="submit" class="btn btn-primary" style="margin-left: 10px;">搜 索</button>
                                    </div>

                                    <table class="table table-striped table-bordered">
                                        <thead>
                                        <tr>
                                            <!--<td><input type="checkbox" class="checkall"-->
                                                       <!--onclick="CheckAll(this.checked);"/></td>-->
                                            <th>订 单 号</th>
                                            <th>店铺名称</th>
                                            <th>买家账号</th>
                                            <th>下单时间</th>
                                            <th>订单总额</th>
                                            <th>运费</th>
                                            <th>支付方式</th>
                                            <th>订单状态</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>

                                        <tbody>
                                        {empty name="data"}
                                        <tr><td colspan="8"><div style='font-size:24px;margin:30px 0;'>没有找到记录</div></td></tr>
                                        {/empty}
                                        {volist name="data" id="item"}
                                        <tr>
                                            <!--<td><input type="checkbox" name="id[]" value="{$item.id}"/></td>-->
                                            <td>{$item.shop_order_number}</td>
                                            <td>{$item.title}</td>
                                            <td>{$item.username}</td>
                                            <td>{$item.create_time|date='Y-m-d H:i:s',###}</td>
                                            <td>{$item.price}</td>
                                            <td>{$item.freight}</td>
                                            <td>{$item.way}</td>
                                            <td>
                                                {switch name="item.status"}
                                                    {case value="0"}未支付{/case}
                                                    {case value="1"}已支付{/case}
                                                    {case value="2"}已发货{/case}
                                                    {case value="3"}已收货{/case}
                                                    {case value="4"}已完结{/case}
                                                    {case value="5"}已取消{/case}
                                                    {case value="6"}申请退款{/case}
                                                    {case value="7"}申请退货{/case}
                                                    {case value="9"}退货中 {/case}
                                                    {case value="10"}退货退款成功 {/case}
                                                    {case value="11"}退货退款失败{/case}
                                                    {default /}出错啦
                                                {/switch}
                                            </td>
                                            <td>
                                                <a href="{:url('member_order/examine', ['id' => $item['id']])}"
                                                   class="label label-primary">
                                                    <span class="fa fa-pencil"></span>&nbsp;&nbsp;查 看
                                                </a>
                                            </td>
                                        </tr>
                                        {/volist}
                                        </tbody>
                                    </table>
                                    <!-- 分页 -->
                                    <div style="float: right;margin-top: -30px;">{$data->render()}</div>
                                    <button type="button" class="btn btn-success" style="margin-top: 20px;" onclick="dc()">订单数：{$total_order}单</button>
                                    <button type="button" class="btn btn-danger" style="margin-top: 20px;" onclick="dc()">销售总金额：{$total_account}元</button>
                                    <button type="button" class="btn btn-info" style="margin-top: 20px;" onclick="dc()">订单导出</button>
                                </form>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

        </div>
        <!-- /page content -->
    </div>

</div>

{include file="public_foot" /}
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<!-- daterangepicker -->
<script src="__STATIC__/js/datepicker/daterangepicker.js"></script>
<!-- public -->
<script src="__STATIC__/js/public.js"></script>
<!-- layer -->
<script src="__STATIC__/js/layer.js"></script>
<script type="text/javascript">
    // list
    $(document).ready(function () {
        // select2
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
        // interval_timer
        $('#interval_timer').daterangepicker(null,
            function(start, end, label) {
//                console.log(start.toISOString(), end.toISOString(), label);
            });
    });

    //导出excel表格
    function dc(){
        var both = $('#interval_timer').val();
        var status = $('#status').val();

        if (both=='') {
            layer.msg('时间区间不能为空!');
            return;
        }if (status<0) {
            layer.msg('状态不能为空!');
            return;
        }
        var both_arr = both.split("/");
        if (both_arr[0] == both_arr[1]){
            layer.msg('请选择时间区间为同1天!');
            return;
        }
        window.location.href = "{:url('client/member_order/export')}?interval_timer="+both+"&status="+status;
    }
</script>